#!/bin/bash

echo "🚀 啟動簡化演示..."

# 確保插件已安裝
echo "📦 檢查插件安裝..."
if [ ! -d "node_modules/gitbook-plugin-gitcode-issue-feedback" ]; then
    echo "🔧 安裝本地插件..."
    mkdir -p "node_modules/gitbook-plugin-gitcode-issue-feedback"
    cp ../index.js "node_modules/gitbook-plugin-gitcode-issue-feedback/"
    cp ../package.json "node_modules/gitbook-plugin-gitcode-issue-feedback/"
    mkdir -p "node_modules/gitbook-plugin-gitcode-issue-feedback/assets"
    cp ../assets/plugin.js "node_modules/gitbook-plugin-gitcode-issue-feedback/assets/"
    echo "✅ 插件安裝完成"
fi

# 直接啟動 GitBook 服務器
echo "🌐 啟動 GitBook 服務器..."
echo "📍 訪問地址: http://localhost:4000"
echo "⏹️  按 Ctrl+C 停止服務器"
echo ""

# 使用 npx 來避免 Node.js 版本問題
npx gitbook serve --port 4000
